#include <iostream>
#include "IndexOptr.h"

using namespace std;

class A{
public:
	A(){
		cout << "A" << endl;
	}
	virtual ~A(){
		cout << "~A" << endl;
	}
};

class B : public A{
public:
	B(){
		cout << "B" << endl;
	}
	virtual ~B(){
		cout << "~B" << endl;
	}
};

int main(){
	A *a = new B();
	delete a;

	int ia[][4] = {{1, 2, 3, 4}, {1, 2, 3, 4}, {1, 2, 3, 4}};
	int (*iaptr)[4] = ia;
	cout << sizeof(ia) << endl; // 48

	IndexOptr iptr;
	iptr[ELEMENT_SIZE - 1] = 0;
	try{
		for(int i = 0; i <= ELEMENT_SIZE; i ++){
			cout << "iptr[" << i << "]: " << iptr[i] << endl;
		}
	}catch(const OutOfBoundaryException& oobe){
		cout << "OutOfBoundaryException: " << oobe.what();
	}
	catch(const range_error& rangeErr){
		cout << "range_error: " << rangeErr.what();
	}
	catch(exception& err){
		cout << "exception: " << err.what();
	}
	catch(...){
		cout << "Some unexpected error encountered. Unhandled and thrown." << endl;
		throw;
	}
	/* infinite loop -- unknown result printed.
	while(iptr.ele != NULL)
	{
		cout << *iptr.ele++ << endl;
	}
	*/
	

	return 0;
}